#ifndef QB_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_UNIX_H_
#define QB_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_UNIX_H_

#include <string>
#include <vector>

namespace qb {

inline bool split(const std::string& src, std::string delimit, std::vector<std::string> &v, std::string null_subst)
{
	if(src.empty() || delimit.empty()) 
	{
		return false;
	}

	uint32_t deli_len = delimit.size();  
	long index = -1,last_search_position = 0;  
	while((index = src.find(delimit,last_search_position)) != -1)  
	{  
		if(index==last_search_position)  
			v.push_back(null_subst);  
		else  
			v.push_back( src.substr(last_search_position, index-last_search_position) );  
		last_search_position = index + deli_len;  
	}

	std::string last_one = src.substr(last_search_position);  
	v.push_back( last_one.empty()? null_subst:last_one);

	return true;
}

}  // namespace qb

#endif  // QB_SYSTEM_WRAPPERS_INTERFACE_UTF_UTIL_UNIX_H_
